//
//  AddAddressViewController.m
//  EasyToTesco
//
//  Created by mc on 16/3/21.
//  Copyright © 2016年 Jack. All rights reserved.
//

#import "AddAddressViewController.h"
#import "HeaderFileForEasyToTesco.h"

@interface AddAddressViewController ()<UITextFieldDelegate, UITextViewDelegate>

@property (nonatomic, strong)UITextField *nameTextfeild;
@property (nonatomic, strong)UITextField *phoneTextfeild;
@property (nonatomic, strong)UITextField *YBtextfeild;
@property (nonatomic, strong)UILabel *cityLabel;
@property (nonatomic, strong)UILabel *streetLabel;
@property (nonatomic, strong)UITextView *detailAddress;




@end

@implementation AddAddressViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self addaddresstopviewui];
    
    [self addotherViewUI];
    
}
- (void)addaddresstopviewui {
    
    UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, (self.secondView.frame.size.height-20)/2, 20, 20)];
    image1.image = [UIImage imageNamed:@"goback-icon.png"];
    [self.secondView addSubview:image1];
    self.leftBtn.hidden = YES;
    
    UIButton *goBackBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    goBackBtn.frame = CGRectMake(0, 0, self.secondView.frame.size.height, self.secondView.frame.size.height);
    [goBackBtn addTarget:self action:@selector(gobackClick) forControlEvents:UIControlEventTouchUpInside];
    [self.secondView addSubview:goBackBtn];
    self.titleLabel.text = @"添加收货地址";

}
- (void)gobackClick {
    [self dismissViewControllerAnimated:YES completion:nil];
}


- (void)addotherViewUI {
    self.nameTextfeild = [[UITextField alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.secondView.frame), WEITH-20, 30)];
    self.nameTextfeild.delegate = self;
    self.nameTextfeild.clearButtonMode = UITextFieldViewModeAlways;
    self.nameTextfeild.placeholder = @"收货人姓名";
    self.nameTextfeild.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.nameTextfeild];
    
    self.phoneTextfeild = [[UITextField alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.nameTextfeild.frame), WEITH-20, 30)];
    self.phoneTextfeild.delegate = self;
    self.phoneTextfeild.placeholder = @"收货人电话";
    self.phoneTextfeild.clearButtonMode = UITextFieldViewModeAlways;
    self.phoneTextfeild.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.phoneTextfeild];
    
    self.YBtextfeild = [[UITextField alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.phoneTextfeild.frame), WEITH-20, 30)];
    self.YBtextfeild.delegate = self;
    self.YBtextfeild.placeholder = @"邮政编码";
    self.YBtextfeild.font = [UIFont systemFontOfSize:14];
    self.YBtextfeild.clearButtonMode = UITextFieldViewModeAlways;
    [self.view addSubview:self.YBtextfeild];
    
    
    self.cityLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.YBtextfeild.frame), WEITH-20, 30)];
    self.cityLabel.text = @"省,市,区";
    self.cityLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.cityLabel];
    
    self.streetLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.cityLabel.frame), WEITH-20, 30)];
    self.streetLabel.text = @"省,市,区";
    self.streetLabel.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.streetLabel];
    
    self.detailAddress = [[UITextView alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(self.streetLabel.frame), WEITH-20, 60)];
    self.detailAddress.delegate = self;
  
    
    self.detailAddress.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:self.detailAddress];
    
    for (NSInteger i=0; i<5; i++) {
        UIView *lineview = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.nameTextfeild.frame)+30*i, WEITH, 1)];
        lineview.backgroundColor = [UIColor grayColor];
        lineview.layer.borderWidth = 1;
        [self.view addSubview:lineview];
    }
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [super touchesBegan:touches withEvent:event];
    [self.view endEditing:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
